/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package service;

import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateful;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import model.Filial;

/**
 *
 * @author Omar
 */
@Stateful(mappedName="FilialBean")
public class FilialFacade implements FilialFacadeRemote {

    @PersistenceContext(unitName="FilialPU")
    private EntityManager em;
   
    @Override
    public void create(Filial filial) {
         em.persist(filial);
    }

    @Override
    public void remove(Filial filial) {
         em.remove(em.merge(filial));
    }

    @Override
    public Filial find(Object id) {
           return em.find(Filial.class, id);
    }

    @Override
    public List<Filial> findAll() {
          return em.createQuery("select object(o) from Filial as o").getResultList();
    }

   /* @Override
    public List<Filial> findCarros(Object id) {
          return em.createQuery("select object(o) from c as o").getResultList();
    }

    */
}
